import request from '../../utils/request.js'

// 申请材料附件 API接口
const apl_attachmentApi = {
  list: '/apl_attachment/list',
  save: '/apl_attachment/save',
  view: '/apl_attachment/view',
  del: '/apl_attachment/delete',
  dels: '/apl_attachment/batchDel',
  output: '/apl_attachment/output',
  exportExcelTemplate: '/apl_attachment/exportExcelTemplate',
  importExcel: '/apl_attachment/importExcel',
  queryList: '/apl_attachment/queryList',
  queryListByMatterAttachid: '/apl_attachment/queryListByMatterAttachid',
  syncSaveAll: '/apl_attachment/syncSaveAll',
  syncSave: '/apl_attachment/syncSave',
  syncRemove: '/apl_attachment/syncRemove'
}

/**
 * 导入申请材料附件Excel
 */
export function importExcel (data) {
  var body = new FormData()
  body.append('file', data)
  return request({
    url: apl_attachmentApi.importExcel,
    headers: { 'Content-Type': 'multipart/form-data' },
    method: 'post',
    data: body
  })
}

/**
 * 导出申请材料附件Excel模板
 */
export function exportExcelTemplate () {
  return request({
    url: apl_attachmentApi.exportExcelTemplate,
    method: 'post',
    responseType: 'blob'
  })
}

/**
 * 导出申请材料附件
 */
export function output (data) {
  return request({
    url: apl_attachmentApi.output,
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}
/**
 * 批量删除申请材料附件
 * @param {*} ids
 */
export function delApl_attachments (ids) {
  return request({
    url: apl_attachmentApi.dels,
    method: 'post',
    params: { ids }
  })
}
/**
 * 删除申请材料附件
 * @param {*} id
 */
export function delApl_attachment (id) {
  return request({
    url: apl_attachmentApi.del,
    method: 'post',
    params: { id }
  })
}
/**
 * 查看、编辑申请材料附件
 * @param {*} id
 */
export function viewApl_attachment (id) {
  return request({
    url: apl_attachmentApi.view,
    method: 'get',
    params: { id }
  })
}
/**
 * 保存申请材料附件
 * @param {*} body
 */
export function saveApl_attachment (body) {
  return request({
    url: apl_attachmentApi.save,
    method: 'post',
    data: body
  })
}
/**
 * 查询申请材料附件列表
 * @param {*} body
 */
export function queryApl_attachmentList (body) {
  return request({
    url: apl_attachmentApi.list,
    method: 'post',
    data: body
  })
}

/**
 * 获取申请材料附件列表
 * @param {*} parameter
 * @returns
 */
export function queryAttachmentList (parameter) {
  return request({
    url: apl_attachmentApi.queryList,
    method: 'get',
    params: parameter
  })
}

/**
 * 获取申请材料附件列表
 * @param {matter_attachid} params 申请材料id
 * @returns
 */
export function queryListByMatterAttachid (params) {
  return request({
    url: apl_attachmentApi.queryListByMatterAttachid,
    method: 'get',
    params: params
  })
}

/**
 * 同步保存所有材料附件
 * @param {applyid, matter_attachid} params 申请id 申请材料id
 * @param {attachmentids} body 附件ids
 * @returns
 */
export function syncSaveAll (params, body) {
  return request({
    url: apl_attachmentApi.syncSaveAll,
    method: 'post',
    params: params,
    data: body
  })
}

/**
 * 同步保存材料附件
 * @param {*} body
 * @returns
 */
export function syncSave (body) {
  return request({
    url: apl_attachmentApi.syncSave,
    method: 'post',
    data: body
  })
}

/**
 * 同步删除材料附件
 * @param {*} id
 * @returns
 */
export function syncRemove (id) {
  return request({
    url: apl_attachmentApi.syncRemove,
    method: 'post',
    params: { id }
  })
}
